package com.sumainfor.schedule.service.impl;

import com.sumainfor.common.Constants;
import com.sumainfor.common.util.ContextUtils;
import com.sumainfor.common.util.FieldCheckUtil;
import com.sumainfor.common.utlis.*;
import com.sumainfor.schedule.dao.ActivityMapper;
import com.sumainfor.schedule.dao.HousingMapper;
import com.sumainfor.schedule.dao.UtilsMapper;
import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

import java.util.*;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 功能描述:
 *
 * @Auther: zhlu
 * @Date: 2019/2/26 10:11
 * @Description:
 */
@Service
public class ActivityService {
    private ReentrantLock lock = new ReentrantLock(false);
    Logger log= LoggerFactory.getLogger(ActivityService.class);

    @Autowired
    ActivityMapper ActivityMapper;

    @Autowired
    HousingMapper HousingMapper;

    @Autowired
    UtilsMapper utilsMapper;

    String QuFulId=null;

    String QuPayId=null;

    String QuSendId=null;

    String QuFirstId=null;

    //房源活动最优价-主表
    String QuActId=null;

    /**
     * 功能描述: 
     * 获取所有的活动，判断活动有效期
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/2/26 10:13
     */
    @Transactional(rollbackFor = Exception.class)
    public void getActivityList(Map<String,Object> params){
        try {
            List<Map<String,Object>>getActivityList=ActivityMapper.getActivityList(params);
            if(getActivityList.size()>0){
                for (Map<String,Object> map:getActivityList){
    //                log.info("map-----"+map);
                    //判断是否是长期活动,判断不是长期活动的
                    if(map.get("IfLong").equals(0)){
                        //判断正常的活动和停用的活动。已过期的活动不管
                        if(map.get("Status").equals(0)||map.get("Status").equals(1)){
                            log.info("EndTime-----------"+map.get("EndTime"));
                            //比较当前的日期 如果当前日期大于传入参数返回负数，小于则返回正数
                            log.info("和当前时间比较之后:"+ConvertDateTime.compare_date(map.get("EndTime").toString()));
                            int maturity=ConvertDateTime.compare_date(map.get("EndTime").toString());
                            //如果当前数据返回的值小于或者等于0，说明已过期。那就该活动修改为已过期
                            if(maturity<=0){
                                //修改处理
                                Map<String, Object> commonUpdateParms = new HashMap<String, Object>();
                                commonUpdateParms.put("term", "8");// 创建端 Insert端： 1 租客端 2市场部 3 工程部   4运营部   5财务部  6总经办 7发展部
                                commonUpdateParms.put("fnc",
                                        this.getClass().getSimpleName() + "." + Thread.currentThread().getStackTrace()[1].getMethodName());// 创建Function名
                                ParamsCommon.commonUpdateParms(commonUpdateParms);
                                //已过期
                                map.put("Status","2");
                                map.putAll(commonUpdateParms);
                                ActivityMapper.UpActivity(map);
                                //根据已过期活动编号查询所绑定的房源
                                List<Map<String,Object>>getActHousingList=ActivityMapper.getActHousingList(map);
                                for(Map<String,Object> act:getActHousingList){
                                    getActivityHousingList(new HashMap<String,Object>(){{
                                        put("delfg","0");
                                        put("Status","0");
                                        put("HouInfoId",act.get("HouInfoId"));
                                    }});
                                }
                            }
                        }
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
    }

    /**
     * 功能描述:
     * 获取所有有效活动,计算出最优活动
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/2/26 17:49
     */
    public void getActivityHousingList(Map<String,Object>params){
        List<Map<String,Object>>getActivityHousingList=ActivityMapper.getActivityHousingList(params);

        List<Map<String,Object>>QuiteHousing=new ArrayList<Map<String,Object>>();

        /**
         * 加锁操作
         */
        lock.lock();
        try {
            //获取所有活动
            if(getActivityHousingList.size()>0){

                //清空活动定价比较记录-主表
                ActivityMapper.DelAllActivityQuite(params);
                //清空活动定价比较记录-首月
                ActivityMapper.DelAllActivityQuiteFirst(params);
                //清空活动定价比较记录-折扣
                ActivityMapper.DelAllActivityQuiteFull(params);
                //清空各活动房源定价
                ActivityMapper.DelAllActivityQuiteHousing(params);
                //清空活动定价比较记录-详表
                ActivityMapper.DelAllActivityQuiteInfo(params);
                //清空活动定价比较记录-付款周期
                ActivityMapper.DelAllActivityQuitePay(params);
                //清空活动定价比较记录-满送
                ActivityMapper.DelAllActivityQuiteSend(params);

                //循环所有活动
                for(Map<String,Object> map:getActivityHousingList){

                    //最优定价
                    double UnifiedPricing=0;
                    //支付渠道   0.线上/转账支付    1.渠道支付
                    if(map.get("PayType").equals(0)){
                        log.info("活动资料："+map);
                        //获取当前活动所有房源
                        String[]HouInfoIdList=map.get("HouInfoIdList").toString().split(";");
                        for(String str:HouInfoIdList){
                            //根据房源编号获取房源资料
                            Map<String,Object>getHousingInfoMap=HousingMapper.getHousingInfoMap(new HashMap<String, Object>(){{
                                put("HouInfoId",str);
                                put("delfg",0);
                            }});
                            log.info("房源资料："+getHousingInfoMap);
                            //获取活动-满减（折扣）活动列表
                            List<Map<String,Object>>getActivityFulList=ActivityMapper.getActivityFulList(map);
                            //给活动-满减（折扣）集合排序
                            Collections.sort(getActivityFulList, new Comparator<Map<String, Object>>() {
                                public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                                    Integer FulDuration1 = Integer.valueOf(o1.get("FulDuration").toString()) ;//从你list里面拿出来的一个
                                    Integer FulDuration2 = Integer.valueOf(o2.get("FulDuration").toString()) ; //从你list里面拿出来的第二个
                                    return FulDuration1.compareTo(FulDuration2);
                                }
                            });
                            //获取付款周期活动列表
                            List<Map<String,Object>>getActivityPayList=ActivityMapper.getActivityPayList(map);
                            //根据活动编号获取活动-首月
                            Map<String,Object>getActivityFirstMap=ActivityMapper.getActivityFirstMap(map);
                            //根据活动编号获取活动-满送
                            Map<String,Object>getActivitySendMap=ActivityMapper.getActivitySendMap(map);
                            //当前房源的定价
                            UnifiedPricing=Double.valueOf(getHousingInfoMap.get("UnifiedPricing").toString());

                            //当前房源活动集合
                            List<Map<String,Object>>housingActivity=new ArrayList<Map<String,Object>>();
                            if(getActivityFulList.size()>0){
                                //判断折扣活动中定价之后活动价
                                for(int i=0;i<getActivityFulList.size();i++){

                                    //各折扣活动优惠价
                                    List<Map<String,Object>>housingFul=new ArrayList<Map<String,Object>>();
//                                for(Map<String,Object> ful:getActivityFulList){
                                    //查询活动定价比较记录-折扣
                                    Map<String,Object>quFulId=utilsMapper.getUUID(new HashMap<String,Object>(){{
                                        put("uuid", "QuFulId");
                                        put("database", Constants.DATA_SOURCE_TCMKT);
                                        put("surface", "tcmkt_activity_quite_full");
                                    }});
                                    if(quFulId!=null){
                                        int number=Integer.valueOf(quFulId.get("uuid").toString());
                                        QuFulId= ComUtils.getLocalTrmSeqNum("bjzk",number);
                                    }else{
                                        QuFulId=ComUtils.getLocalTrmSeqNum("bjzk",0);
                                    }

                                    //折扣活动中最优价格
                                    double FulActPrice=0;
                                    if(FieldCheckUtil.isMapFieldNotNull(getActivityFulList.get(i),new String[]{"FulOff"})){
                                        double discount=CompuUtils.div(Double.valueOf(getActivityFulList.get(i).get("FulOff").toString()),10);
                                        FulActPrice= CompuUtils.mul(UnifiedPricing,discount);
                                    }
                                    if(FieldCheckUtil.isMapFieldNotNull(getActivityFulList.get(i),new String[]{"FulMoney"})){
                                        FulActPrice= CompuUtils.reduce(UnifiedPricing,Double.valueOf(getActivityFulList.get(i).get("FulMoney").toString()));
                                    }


                                    //创建活动定价比较记录-折扣
                                    Map<String,Object>ActivityQuiteFull=new HashMap<String,Object>();
                                    ActivityQuiteFull.put("QuFulId",QuFulId);
                                    ActivityQuiteFull.put("ActId",map.get("ActId"));
                                    ActivityQuiteFull.put("HouInfoId",str);
                                    ActivityQuiteFull.put("SouPricing",UnifiedPricing);
                                    ActivityQuiteFull.put("ActType",1);
                                    ActivityQuiteFull.put("FulDuration",getActivityFulList.get(i).get("FulDuration").toString());
                                    ActivityQuiteFull.put("FulMoney",getActivityFulList.get(i).get("FulMoney"));
                                    ActivityQuiteFull.put("FulOff",getActivityFulList.get(i).get("FulOff"));
                                    ActivityQuiteFull.put("Pricing",FulActPrice);

                                    //把当前折扣活动比较价格对象添加至集合
                                    housingFul.add(new HashMap<String,Object>(){{
                                        put("ActType",1);
                                        put("AssId",QuFulId);
                                        put("Duration",ActivityQuiteFull.get("FulDuration"));
                                        put("Pricing",ActivityQuiteFull.get("Pricing"));
                                    }});

                                    //创建定价比较记录详表
                                    AddActivityQuiteFull(ActivityQuiteFull);

                                    //付款周期活动比较
                                    if(getActivityPayList.size()>0){
                                        //判断付款周期活动中定价之后活动价
                                        for(Map<String,Object> pay:getActivityPayList){
                                            //实际付款周期   月1  季3  半年6   年付12
                                            int Signing=Integer.valueOf(pay.get("Signing").toString());
                                            //获取折扣活动签约时长
                                            int FulDuration=Integer.valueOf(getActivityFulList.get(i).get("FulDuration").toString());
                                            double ActPayPrice=0;
                                            if(FulDuration>=Signing||i==(getActivityFulList.size()-1)){
                                                if(FieldCheckUtil.isMapFieldNotNull(pay,new String[]{"FulOff"})){
                                                    double discount=CompuUtils.div(Double.valueOf(pay.get("FulOff").toString()),10);
                                                    ActPayPrice= CompuUtils.mul(FulActPrice,discount);
                                                }
                                                if(FieldCheckUtil.isMapFieldNotNull(pay,new String[]{"FulMoney"})){
                                                    ActPayPrice= CompuUtils.reduce(FulActPrice,Double.valueOf(pay.get("FulMoney").toString()));
                                                }

                                                //查询活动定价比较记录-折扣
                                                Map<String,Object>quPayId=utilsMapper.getUUID(new HashMap<String,Object>(){{
                                                    put("uuid", "QuPayId");
                                                    put("database", Constants.DATA_SOURCE_TCMKT);
                                                    put("surface", "tcmkt_activity_quite_pay");
                                                }});
                                                if(quPayId!=null){
                                                    int number=Integer.valueOf(quPayId.get("uuid").toString());
                                                    QuPayId= ComUtils.getLocalTrmSeqNum("bjfk",number);
                                                }else{
                                                    QuPayId=ComUtils.getLocalTrmSeqNum("bjfk",0);
                                                }

                                                //创建活动定价比较记录-付款周期
                                                Map<String,Object>ActivityQuitePay=new HashMap<String,Object>();
                                                ActivityQuitePay.put("QuPayId",QuPayId);
                                                ActivityQuitePay.put("ActId",map.get("ActId"));
                                                ActivityQuitePay.put("HouInfoId",str);
                                                ActivityQuitePay.put("SouType",1);
                                                ActivityQuitePay.put("SouId",QuFulId);
                                                ActivityQuitePay.put("SouPricing",FulActPrice);
                                                ActivityQuitePay.put("FulDuration",getActivityFulList.get(i).get("FulDuration"));
                                                ActivityQuitePay.put("ActType",2);
                                                ActivityQuitePay.put("PayType",pay.get("PayType"));
                                                ActivityQuitePay.put("FulMoney",pay.get("FulMoney"));
                                                ActivityQuitePay.put("FulOff",pay.get("FulOff"));
                                                ActivityQuitePay.put("Pricing",ActPayPrice);

                                                //把当前付款周期活动比较价格对象添加至集合
                                                housingFul.add(new HashMap<String,Object>(){{
                                                    put("ActType",2);
                                                    put("AssId",QuPayId);
                                                    put("Duration",ActivityQuitePay.get("FulDuration"));
                                                    put("Pricing",ActivityQuitePay.get("Pricing"));
                                                }});

                                                //创建活动定价比较记录-付款周期
                                                AddActivityQuitePay(ActivityQuitePay);

                                            }

                                            //如果满送不为空
                                            if(getActivitySendMap!=null && getActivitySendMap.size()>0){
                                                double ActSendPrice=0;
                                                //获取活动-满送签约满时长
                                                int SenDuration=Integer.valueOf(getActivitySendMap.get("SenDuration").toString());
                                                //先判断折扣活动签约时长是否大于活动-满送签约满时长
                                                if(FulDuration>=SenDuration){
                                                    //实际签约总租金=折扣签约时长*折扣价
                                                    double Totallength=CompuUtils.mul(FulDuration,ActPayPrice);
                                                    //(签约时长+送时长)
                                                    double Duration=CompuUtils.add(FulDuration,Double.valueOf(getActivitySendMap.get("SenSend").toString()));
                                                    //实际签约总租金/(签约时长+送时长)
                                                    ActSendPrice=CompuUtils.div(Totallength,Duration,2);

                                                    //查询活动定价比较记录-满送
                                                    Map<String,Object>quSendId=utilsMapper.getUUID(new HashMap<String,Object>(){{
                                                        put("uuid", "QuSendId");
                                                        put("database", Constants.DATA_SOURCE_TCMKT);
                                                        put("surface", "tcmkt_activity_quite_send");
                                                    }});
                                                    if(quSendId!=null){
                                                        int number=Integer.valueOf(quSendId.get("uuid").toString());
                                                        QuSendId= ComUtils.getLocalTrmSeqNum("bjms",number);
                                                    }else{
                                                        QuSendId=ComUtils.getLocalTrmSeqNum("bjms",0);
                                                    }

                                                    //创建活动定价比较记录-满送
                                                    Map<String,Object>ActivityQuiteSend=new HashMap<String,Object>();
                                                    ActivityQuiteSend.put("QuSendId",QuSendId);
                                                    ActivityQuiteSend.put("ActId",map.get("ActId"));
                                                    ActivityQuiteSend.put("HouInfoId",str);
                                                    ActivityQuiteSend.put("SouType",2);
                                                    ActivityQuiteSend.put("SouId",QuPayId);
                                                    ActivityQuiteSend.put("SouPricing",ActPayPrice);
                                                    ActivityQuiteSend.put("FulDuration",getActivityFulList.get(i).get("FulDuration"));
                                                    ActivityQuiteSend.put("Duration",getActivityFulList.get(i).get("FulDuration"));
                                                    ActivityQuiteSend.put("ActType",3);
                                                    ActivityQuiteSend.put("SenSend",getActivitySendMap.get("SenSend"));
                                                    ActivityQuiteSend.put("Pricing",ActSendPrice);
                                                    //把当前活动定价比较记录-满送比较价格对象添加至集合
                                                    housingFul.add(new HashMap<String,Object>(){{
                                                        put("ActType",3);
                                                        put("AssId",QuSendId);
                                                        put("Duration",ActivityQuiteSend.get("Duration"));
                                                        put("Pricing",ActivityQuiteSend.get("Pricing"));
                                                    }});

                                                    //创建活动定价比较记录-满送
                                                    AddActivityQuiteSend(ActivityQuiteSend);

                                                    //首月活动
                                                    if(getActivityFirstMap!=null && getActivityFirstMap.size()>0){
                                                        double ActFirstPrice=0;
                                                        //获取首月活动签约满时长
                                                        int FirstDuration=Integer.valueOf(getActivityFirstMap.get("FulDuration").toString());
                                                        //先判断折扣活动签约时长是否大于首月签约时长
                                                        if(FulDuration>=FirstDuration){
                                                            //判断首月是打折还是减金额
                                                            //打折
                                                            if(FieldCheckUtil.isMapFieldNotNull(getActivityFirstMap,new String[]{"FulOff"})){
                                                                //第一步：获取首月价格=满送优惠价*折扣
                                                                double FirstMo=CompuUtils.mul(ActSendPrice,CompuUtils.div(Double.valueOf(getActivityFirstMap.get("FulOff").toString()),10));
                                                                //第二步：(折扣签约时长-1)
                                                                double duration1=CompuUtils.reduce(Double.valueOf(getActivityFulList.get(i).get("FulDuration").toString()),1);
                                                                //第三步：总价格：满送优惠价*(折扣签约时长-1)
                                                                double Totalcost1=CompuUtils.mul(ActSendPrice,duration1);
                                                                //第三步：总价格+首月价格
                                                                double Totalcost=CompuUtils.add(Totalcost1,FirstMo);
                                                                //第四步：首月优惠价：总价格/折扣签约时长
                                                                ActFirstPrice=CompuUtils.div(Totalcost,Double.valueOf(getActivityFulList.get(i).get("FulDuration").toString()),2);
                                                            }
                                                            if(FieldCheckUtil.isMapFieldNotNull(getActivityFirstMap,new String[]{"FulMoney"})){
                                                                //第一步：总价格:折扣签约时长*满送价格
                                                                double Totalcost1=CompuUtils.mul(Double.valueOf(getActivityFulList.get(i).get("FulDuration").toString()),ActSendPrice);
                                                                //第二步：总价格：总价格-首月立减金额
                                                                double Totalcost=CompuUtils.reduce(Totalcost1,Double.valueOf(getActivityFirstMap.get("FulMoney").toString()));
                                                                //第三步：首月优惠价：总价格/折扣签约时长
                                                                ActFirstPrice=CompuUtils.div(Totalcost,Double.valueOf(getActivityFulList.get(i).get("FulDuration").toString()),2);
                                                            }

                                                            //查询活动定价比较记录-满送
                                                            Map<String,Object>quFirstId=utilsMapper.getUUID(new HashMap<String,Object>(){{
                                                                put("uuid", "QuFirstId");
                                                                put("database", Constants.DATA_SOURCE_TCMKT);
                                                                put("surface", "tcmkt_activity_quite_first");
                                                            }});
                                                            if(quFirstId!=null){
                                                                int number=Integer.valueOf(quFirstId.get("uuid").toString());
                                                                QuFirstId= ComUtils.getLocalTrmSeqNum("bjsy",number);
                                                            }else{
                                                                QuFirstId=ComUtils.getLocalTrmSeqNum("bjsy",0);
                                                            }

                                                            //创建活动定价比较记录-首月
                                                            Map<String,Object>ActivityQuiteFirst=new HashMap<String,Object>();
                                                            ActivityQuiteFirst.put("QuFirstId",QuFirstId);
                                                            ActivityQuiteFirst.put("ActId",map.get("ActId"));
                                                            ActivityQuiteFirst.put("HouInfoId",str);
                                                            ActivityQuiteFirst.put("SouType",3);
                                                            ActivityQuiteFirst.put("SouId",QuSendId);
                                                            ActivityQuiteFirst.put("SouPricing",ActSendPrice);
                                                            ActivityQuiteFirst.put("FulDuration",getActivityFulList.get(i).get("FulDuration"));
                                                            ActivityQuiteFirst.put("Duration",getActivityFulList.get(i).get("FulDuration"));
                                                            ActivityQuiteFirst.put("ActType",4);
                                                            ActivityQuiteFirst.put("FirDuration",getActivityFirstMap.get("FulDuration"));
                                                            ActivityQuiteFirst.put("FulMoney",getActivityFirstMap.get("FulMoney"));
                                                            ActivityQuiteFirst.put("FulOff",getActivityFirstMap.get("FulOff"));
                                                            ActivityQuiteFirst.put("Pricing",ActFirstPrice);
                                                            //把当前活动定价比较记录-首月比较价格对象添加至集合
                                                            housingFul.add(new HashMap<String,Object>(){{
                                                                put("ActType",4);
                                                                put("AssId",QuFirstId);
                                                                put("Duration",ActivityQuiteFirst.get("Duration"));
                                                                put("Pricing",ActivityQuiteFirst.get("Pricing"));
                                                            }});

                                                            //创建活动定价比较记录-首月
                                                            AddActivityQuiteFirst(ActivityQuiteFirst);

                                                        }

                                                    }

                                                }//折扣里面最后一位。直接符合满送要求
                                                else if(i==(getActivityFulList.size()-1)){
                                                    //实际签约总租金=满送签约时长*折扣价
                                                    double Totallength=CompuUtils.mul(Double.valueOf(getActivitySendMap.get("SenDuration").toString()),ActPayPrice);
                                                    //(满送时长+送时长)
                                                    double Duration=CompuUtils.add(Double.valueOf(getActivitySendMap.get("SenDuration").toString()),Double.valueOf(getActivitySendMap.get("SenSend").toString()));
                                                    //实际签约总租金/(满送时长+送时长)
                                                    ActSendPrice=CompuUtils.div(Totallength,Duration,2);

                                                    //查询活动定价比较记录-满送
                                                    Map<String,Object>quSendId=utilsMapper.getUUID(new HashMap<String,Object>(){{
                                                        put("uuid", "QuSendId");
                                                        put("database", Constants.DATA_SOURCE_TCMKT);
                                                        put("surface", "tcmkt_activity_quite_send");
                                                    }});
                                                    if(quSendId!=null){
                                                        int number=Integer.valueOf(quSendId.get("uuid").toString());
                                                        QuSendId= ComUtils.getLocalTrmSeqNum("bjms",number);
                                                    }else{
                                                        QuSendId=ComUtils.getLocalTrmSeqNum("bjms",0);
                                                    }

                                                    //创建活动定价比较记录-首月
                                                    Map<String,Object>ActivityQuiteSend=new HashMap<String,Object>();
                                                    ActivityQuiteSend.put("QuSendId",QuSendId);
                                                    ActivityQuiteSend.put("ActId",map.get("ActId"));
                                                    ActivityQuiteSend.put("HouInfoId",str);
                                                    ActivityQuiteSend.put("SouType",2);
                                                    ActivityQuiteSend.put("SouId",QuPayId);
                                                    ActivityQuiteSend.put("SouPricing",ActPayPrice);
                                                    ActivityQuiteSend.put("FulDuration",getActivityFulList.get(i).get("FulDuration"));
                                                    ActivityQuiteSend.put("Duration",getActivitySendMap.get("SenDuration"));
                                                    ActivityQuiteSend.put("ActType",3);
                                                    ActivityQuiteSend.put("SenSend",getActivitySendMap.get("SenSend"));
                                                    ActivityQuiteSend.put("Pricing",ActSendPrice);

                                                    //把当前活动定价比较记录-首月比较价格对象添加至集合
                                                    housingFul.add(new HashMap<String,Object>(){{
                                                        put("ActType",3);
                                                        put("AssId",QuFirstId);
                                                        put("Duration",ActivityQuiteSend.get("Duration"));
                                                        put("Pricing",ActivityQuiteSend.get("Pricing"));
                                                    }});

                                                    //创建活动定价比较记录-首月
                                                    AddActivityQuiteSend(ActivityQuiteSend);

                                                    if(getActivityFirstMap!=null && getActivityFirstMap.size()>0){
                                                        double ActFirstPrice=0;
                                                        //判断首月是打折还是减金额
                                                        //打折
                                                        if(FieldCheckUtil.isMapFieldNotNull(getActivityFirstMap,new String[]{"FulOff"})){
                                                            //第一步：获取首月价格=满送优惠价*折扣
                                                            double FirstMo=CompuUtils.mul(ActSendPrice,CompuUtils.div(Double.valueOf(getActivityFirstMap.get("FulOff").toString()),10));
                                                            //第二步：(首月签约时长-1)
                                                            double duration1=CompuUtils.reduce(Double.valueOf(getActivityFirstMap.get("FulDuration").toString()),1);
                                                            //第三步：总价格：满送优惠价*(首月签约时长-1)
                                                            double Totalcost1=CompuUtils.mul(ActSendPrice,duration1);
                                                            //第三步：总价格+首月价格
                                                            double Totalcost=CompuUtils.add(Totalcost1,FirstMo);
                                                            //第四步：首月优惠价：总价格/首月签约时长
                                                            ActFirstPrice=CompuUtils.div(Totalcost,Double.valueOf(getActivityFirstMap.get("FulDuration").toString()),2);
                                                        }
                                                        if(FieldCheckUtil.isMapFieldNotNull(getActivityFirstMap,new String[]{"FulMoney"})){
                                                            //第一步：总价格:首月签约时长*满送价格
                                                            double Totalcost1=CompuUtils.mul(Double.valueOf(getActivityFirstMap.get("FulDuration").toString()),ActSendPrice);
                                                            //第二步：总价格：总价格-首月立减金额
                                                            double Totalcost=CompuUtils.reduce(Totalcost1,Double.valueOf(getActivityFirstMap.get("FulMoney").toString()));
                                                            //第三步：首月优惠价：总价格/首月签约时长
                                                            ActFirstPrice=CompuUtils.div(Totalcost,Double.valueOf(getActivityFirstMap.get("FulDuration").toString()),2);
                                                        }

                                                        //查询活动定价比较记录-满送
                                                        Map<String,Object>quFirstId=utilsMapper.getUUID(new HashMap<String,Object>(){{
                                                            put("uuid", "QuFirstId");
                                                            put("database", Constants.DATA_SOURCE_TCMKT);
                                                            put("surface", "tcmkt_activity_quite_first");
                                                        }});
                                                        if(quFirstId!=null){
                                                            int number=Integer.valueOf(quFirstId.get("uuid").toString());
                                                            QuFirstId= ComUtils.getLocalTrmSeqNum("bjsy",number);
                                                        }else{
                                                            QuFirstId=ComUtils.getLocalTrmSeqNum("bjsy",0);
                                                        }

                                                        //创建活动定价比较记录-首月
                                                        Map<String,Object>ActivityQuiteFirst=new HashMap<String,Object>();
                                                        ActivityQuiteFirst.put("QuFirstId",QuFirstId);
                                                        ActivityQuiteFirst.put("ActId",map.get("ActId"));
                                                        ActivityQuiteFirst.put("HouInfoId",str);
                                                        ActivityQuiteFirst.put("SouType",3);
                                                        ActivityQuiteFirst.put("SouId",QuSendId);
                                                        ActivityQuiteFirst.put("SouPricing",ActSendPrice);
                                                        ActivityQuiteFirst.put("FulDuration",getActivityFulList.get(i).get("FulDuration"));
                                                        ActivityQuiteFirst.put("Duration",getActivityFirstMap.get("FulDuration"));
                                                        ActivityQuiteFirst.put("ActType",4);
                                                        ActivityQuiteFirst.put("FirDuration",getActivityFirstMap.get("FulDuration"));
                                                        ActivityQuiteFirst.put("FulMoney",getActivityFirstMap.get("FulMoney"));
                                                        ActivityQuiteFirst.put("FulOff",getActivityFirstMap.get("FulOff"));
                                                        ActivityQuiteFirst.put("Pricing",ActFirstPrice);

                                                        //把当前活动定价比较记录-首月比较价格对象添加至集合
                                                        housingFul.add(new HashMap<String,Object>(){{
                                                            put("ActType",4);
                                                            put("AssId",QuFirstId);
                                                            put("Duration",ActivityQuiteFirst.get("Duration"));
                                                            put("Pricing",ActivityQuiteFirst.get("Pricing"));
                                                        }});

                                                        //创建活动定价比较记录-首月
                                                        AddActivityQuiteFirst(ActivityQuiteFirst);

                                                    }
                                                }
                                            }
                                        }
                                    }

                                    //给活动-满减（折扣）集合排序
                                    Collections.sort(housingFul, new Comparator<Map<String, Object>>() {
                                        public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                                            Double Pricing1 = Double.valueOf(o1.get("Pricing").toString()) ;//从你list里面拿出来的一个
                                            Double Pricing2 = Double.valueOf(o2.get("Pricing").toString()) ; //从你list里面拿出来的第二个
                                            return Pricing1.compareTo(Pricing2);
                                        }
                                    });

                                    Map<String,Object>housingMap=new HashMap<String,Object>();
                                    housingMap.put("ActType",housingFul.get(0).get("ActType"));
                                    housingMap.put("AssId",housingFul.get(0).get("AssId"));
                                    housingMap.put("Duration",housingFul.get(0).get("Duration"));
                                    housingMap.put("Pricing",housingFul.get(0).get("Pricing"));
//
                                    housingActivity.add(housingMap);
                                }
                            }
                            else if(getActivityPayList.size()>0){

                                //判断付款周期活动中定价之后活动价
//                                for(Map<String,Object> pay:getActivityPayList){
                                for(int i=0;i<getActivityPayList.size();i++){

                                    //各付款周期活动优惠价
                                    List<Map<String,Object>>housingPay=new ArrayList<Map<String,Object>>();

                                    double ActPayPrice=0;
                                    if(FieldCheckUtil.isMapFieldNotNull(getActivityPayList.get(i),new String[]{"FulOff"})){
                                        double discount=CompuUtils.div(Double.valueOf(getActivityPayList.get(i).get("FulOff").toString()),10);
                                        ActPayPrice= CompuUtils.mul(UnifiedPricing,discount);
                                    }
                                    if(FieldCheckUtil.isMapFieldNotNull(getActivityPayList.get(i),new String[]{"FulMoney"})){
                                        ActPayPrice= CompuUtils.reduce(UnifiedPricing,Double.valueOf(getActivityPayList.get(i).get("FulMoney").toString()));
                                    }

                                    //查询活动定价比较记录-折扣
                                    Map<String,Object>quPayId=utilsMapper.getUUID(new HashMap<String,Object>(){{
                                        put("uuid", "QuPayId");
                                        put("database", Constants.DATA_SOURCE_TCMKT);
                                        put("surface", "tcmkt_activity_quite_pay");
                                    }});
                                    if(quPayId!=null){
                                        int number=Integer.valueOf(quPayId.get("uuid").toString());
                                        QuPayId= ComUtils.getLocalTrmSeqNum("bjfk",number);
                                    }else{
                                        QuPayId=ComUtils.getLocalTrmSeqNum("bjfk",0);
                                    }

                                    //创建活动定价比较记录-付款周期
                                    Map<String,Object>ActivityQuitePay=new HashMap<String,Object>();
                                    ActivityQuitePay.put("QuPayId",QuPayId);
                                    ActivityQuitePay.put("ActId",map.get("ActId"));
                                    ActivityQuitePay.put("HouInfoId",str);
                                    ActivityQuitePay.put("SouPricing",UnifiedPricing);
                                    ActivityQuitePay.put("ActType",2);
                                    ActivityQuitePay.put("PayType",getActivityPayList.get(i).get("PayType"));
                                    ActivityQuitePay.put("FulMoney",getActivityPayList.get(i).get("FulMoney"));
                                    ActivityQuitePay.put("FulOff",getActivityPayList.get(i).get("FulOff"));
                                    ActivityQuitePay.put("Pricing",ActPayPrice);

                                    //把当前付款周期活动比较价格对象添加至集合
                                    housingPay.add(new HashMap<String,Object>(){{
                                        put("ActType",2);
                                        put("AssId",QuPayId);
                                        put("Duration",null);
                                        put("Pricing",ActivityQuitePay.get("Pricing"));
                                    }});

                                    //创建活动定价比较记录-付款周期
                                    AddActivityQuitePay(ActivityQuitePay);


                                    //如果满送不为空
                                    if(getActivitySendMap!=null && getActivitySendMap.size()>0){
                                        double ActSendPrice=0;
                                        //获取活动-满送签约满时长
                                        int SenDuration=Integer.valueOf(getActivitySendMap.get("SenDuration").toString());
                                        //实际签约总租金=满送签约时长*折扣价
                                        double Totallength=CompuUtils.mul(Double.valueOf(getActivitySendMap.get("SenDuration").toString()),ActPayPrice);
                                        //(满送时长+送时长)
                                        double Duration=CompuUtils.add(Double.valueOf(getActivitySendMap.get("SenDuration").toString()),Double.valueOf(getActivitySendMap.get("SenSend").toString()));
                                        //实际签约总租金/(满送时长+送时长)
                                        ActSendPrice=CompuUtils.div(Totallength,Duration,2);

                                        //查询活动定价比较记录-满送
                                        Map<String,Object>quSendId=utilsMapper.getUUID(new HashMap<String,Object>(){{
                                            put("uuid", "QuSendId");
                                            put("database", Constants.DATA_SOURCE_TCMKT);
                                            put("surface", "tcmkt_activity_quite_send");
                                        }});
                                        if(quSendId!=null){
                                            int number=Integer.valueOf(quSendId.get("uuid").toString());
                                            QuSendId= ComUtils.getLocalTrmSeqNum("bjms",number);
                                        }else{
                                            QuSendId=ComUtils.getLocalTrmSeqNum("bjms",0);
                                        }

                                        //创建活动定价比较记录-首月
                                        Map<String,Object>ActivityQuiteSend=new HashMap<String,Object>();
                                        ActivityQuiteSend.put("QuSendId",QuSendId);
                                        ActivityQuiteSend.put("ActId",map.get("ActId"));
                                        ActivityQuiteSend.put("HouInfoId",str);
                                        ActivityQuiteSend.put("SouType",2);
                                        ActivityQuiteSend.put("SouId",QuPayId);
                                        ActivityQuiteSend.put("SouPricing",ActPayPrice);
                                        ActivityQuiteSend.put("FulDuration",SenDuration);
                                        ActivityQuiteSend.put("Duration",Double.valueOf(getActivitySendMap.get("SenDuration").toString()));
                                        ActivityQuiteSend.put("ActType",3);
                                        ActivityQuiteSend.put("SenSend",getActivitySendMap.get("SenSend"));
                                        ActivityQuiteSend.put("Pricing",ActSendPrice);

                                        //把当前活动定价比较记录-首月比较价格对象添加至集合
                                        housingPay.add(new HashMap<String,Object>(){{
                                            put("ActType",3);
                                            put("AssId",QuFirstId);
                                            put("Duration",ActivityQuiteSend.get("FulDuration"));
                                            put("Pricing",ActivityQuiteSend.get("Pricing"));
                                        }});

                                        //创建活动定价比较记录-满送
                                        AddActivityQuiteSend(ActivityQuiteSend);

                                        //判断首月
                                        if(getActivityFirstMap!=null && getActivityFirstMap.size()>0){
                                            double ActFirstPrice=0;
                                            //获取首月签约时长
                                            int FirstDuration=Integer.valueOf(getActivityFirstMap.get("FulDuration").toString());

                                            //首月时长
                                            double Dur=0;
                                            //满送时长是否大于首月时长
                                            if(SenDuration>=FirstDuration){
                                                Dur=SenDuration;
                                            }else{
                                                Dur=FirstDuration;
                                            }

                                            //判断首月是打折还是减金额
                                            //打折
                                            if(FieldCheckUtil.isMapFieldNotNull(getActivityFirstMap,new String[]{"FulOff"})){
                                                //第一步：获取首月价格=满送优惠价*折扣
                                                double FirstMo=CompuUtils.mul(ActSendPrice,CompuUtils.div(Double.valueOf(getActivityFirstMap.get("FulOff").toString()),10));
                                                //第二步：(首月签约时长-1)
                                                double duration1=CompuUtils.reduce(Dur,1);
                                                //第三步：总价格：满送优惠价*(首月签约时长-1)
                                                double Totalcost1=CompuUtils.mul(ActSendPrice,duration1);
                                                //第三步：总价格+首月价格
                                                double Totalcost=CompuUtils.add(Totalcost1,FirstMo);
                                                //第四步：首月优惠价：总价格/首月签约时长
                                                ActFirstPrice=CompuUtils.div(Totalcost,Dur,2);
                                            }
                                            if(FieldCheckUtil.isMapFieldNotNull(getActivityFirstMap,new String[]{"FulMoney"})){
                                                //第一步：总价格:首月签约时长*满送价格
                                                double Totalcost1=CompuUtils.mul(Dur,ActSendPrice);
                                                //第二步：总价格：总价格-首月立减金额
                                                double Totalcost=CompuUtils.reduce(Totalcost1,Double.valueOf(getActivityFirstMap.get("FulMoney").toString()));
                                                //第三步：首月优惠价：总价格/首月签约时长
                                                ActFirstPrice=CompuUtils.div(Totalcost,Dur,2);
                                            }

                                            //查询活动定价比较记录-满送
                                            Map<String,Object>quFirstId=utilsMapper.getUUID(new HashMap<String,Object>(){{
                                                put("uuid", "QuFirstId");
                                                put("database", Constants.DATA_SOURCE_TCMKT);
                                                put("surface", "tcmkt_activity_quite_first");
                                            }});
                                            if(quFirstId!=null){
                                                int number=Integer.valueOf(quFirstId.get("uuid").toString());
                                                QuFirstId= ComUtils.getLocalTrmSeqNum("bjsy",number);
                                            }else{
                                                QuFirstId=ComUtils.getLocalTrmSeqNum("bjsy",0);
                                            }

                                            //创建活动定价比较记录-首月
                                            Map<String,Object>ActivityQuiteFirst=new HashMap<String,Object>();
                                            ActivityQuiteFirst.put("QuFirstId",QuFirstId);
                                            ActivityQuiteFirst.put("ActId",map.get("ActId"));
                                            ActivityQuiteFirst.put("HouInfoId",str);
                                            ActivityQuiteFirst.put("SouType",3);
                                            ActivityQuiteFirst.put("SouId",QuSendId);
                                            ActivityQuiteFirst.put("SouPricing",ActSendPrice);
                                            ActivityQuiteFirst.put("Duration",Dur);
                                            ActivityQuiteFirst.put("ActType",4);
                                            ActivityQuiteFirst.put("FirDuration",getActivityFirstMap.get("FulDuration"));
                                            ActivityQuiteFirst.put("FulMoney",getActivityFirstMap.get("FulMoney"));
                                            ActivityQuiteFirst.put("FulOff",getActivityFirstMap.get("FulOff"));
                                            ActivityQuiteFirst.put("Pricing",ActFirstPrice);

                                            //把当前活动定价比较记录-首月比较价格对象添加至集合
                                            housingPay.add(new HashMap<String,Object>(){{
                                                put("ActType",4);
                                                put("AssId",QuFirstId);
                                                put("Duration",ActivityQuiteFirst.get("Duration"));
                                                put("Pricing",ActivityQuiteFirst.get("Pricing"));
                                            }});

                                            //创建活动定价比较记录-首月
                                            AddActivityQuiteFirst(ActivityQuiteFirst);

                                        }
                                    }

                                    //给活动集合排序
                                    Collections.sort(housingPay, new Comparator<Map<String, Object>>() {
                                        public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                                            Double Pricing1 = Double.valueOf(o1.get("Pricing").toString()) ;//从你list里面拿出来的一个
                                            Double Pricing2 = Double.valueOf(o2.get("Pricing").toString()) ; //从你list里面拿出来的第二个
                                            return Pricing1.compareTo(Pricing2);
                                        }
                                    });

                                    Map<String,Object>housingMap=new HashMap<String,Object>();
                                    housingMap.put("ActType",housingPay.get(0).get("ActType"));
                                    housingMap.put("AssId",housingPay.get(0).get("AssId"));
                                    housingMap.put("Duration",housingPay.get(0).get("Duration"));
                                    housingMap.put("Pricing",housingPay.get(0).get("Pricing"));
//
                                    housingActivity.add(housingMap);

                                }

                            }
                            //折扣活动为空&&付款周期为空&满送不为空
                            else if(getActivityFulList.size()<=0&&getActivityPayList.size()<=0&&getActivitySendMap!=null && getActivitySendMap.size()>0){
                                //各付款周期活动优惠价
                                List<Map<String,Object>>housingSend=new ArrayList<Map<String,Object>>();

                                double ActSendPrice=0;
                                //获取活动-满送签约满时长
                                int SenDuration=Integer.valueOf(getActivitySendMap.get("SenDuration").toString());
                                //实际签约总租金=满送签约时长*房源定价
                                double Totallength=CompuUtils.mul(Double.valueOf(getActivitySendMap.get("SenDuration").toString()),UnifiedPricing);
                                //(满送时长+送时长)
                                double Duration=CompuUtils.add(Double.valueOf(getActivitySendMap.get("SenDuration").toString()),Double.valueOf(getActivitySendMap.get("SenSend").toString()));
                                //实际签约总租金/(满送时长+送时长)
                                ActSendPrice=CompuUtils.div(Totallength,Duration,2);

                                //查询活动定价比较记录-满送
                                Map<String,Object>quSendId=utilsMapper.getUUID(new HashMap<String,Object>(){{
                                    put("uuid", "QuSendId");
                                    put("database", Constants.DATA_SOURCE_TCMKT);
                                    put("surface", "tcmkt_activity_quite_send");
                                }});
                                if(quSendId!=null){
                                    int number=Integer.valueOf(quSendId.get("uuid").toString());
                                    QuSendId= ComUtils.getLocalTrmSeqNum("bjms",number);
                                }else{
                                    QuSendId=ComUtils.getLocalTrmSeqNum("bjms",0);
                                }

                                //创建活动定价比较记录-首月
                                Map<String,Object>ActivityQuiteSend=new HashMap<String,Object>();
                                ActivityQuiteSend.put("QuSendId",QuSendId);
                                ActivityQuiteSend.put("ActId",map.get("ActId"));
                                ActivityQuiteSend.put("HouInfoId",str);
                                ActivityQuiteSend.put("SouPricing",UnifiedPricing);
                                ActivityQuiteSend.put("FulDuration",SenDuration);
                                ActivityQuiteSend.put("Duration",Double.valueOf(getActivitySendMap.get("SenDuration").toString()));
                                ActivityQuiteSend.put("ActType",3);
                                ActivityQuiteSend.put("SenSend",getActivitySendMap.get("SenSend"));
                                ActivityQuiteSend.put("Pricing",ActSendPrice);

                                //把当前活动定价比较记录-首月比较价格对象添加至集合
                                housingSend.add(new HashMap<String,Object>(){{
                                    put("ActType",3);
                                    put("AssId",QuFirstId);
                                    put("Duration",ActivityQuiteSend.get("FulDuration"));
                                    put("Pricing",ActivityQuiteSend.get("Pricing"));
                                }});

                                //创建活动定价比较记录-满送
                                AddActivityQuiteSend(ActivityQuiteSend);

                                //判断首月
                                if(getActivityFirstMap!=null && getActivityFirstMap.size()>0){
                                    double ActFirstPrice=0;
                                    //获取首月签约时长
                                    int FirstDuration=Integer.valueOf(getActivityFirstMap.get("FulDuration").toString());

                                    //首月时长
                                    double Dur=0;
                                    //满送时长是否大于首月时长
                                    if(SenDuration>=FirstDuration){
                                        Dur=SenDuration;
                                    }else{
                                        Dur=FirstDuration;
                                    }

                                    //判断首月是打折还是减金额
                                    //打折
                                    if(FieldCheckUtil.isMapFieldNotNull(getActivityFirstMap,new String[]{"FulOff"})){
                                        //第一步：获取首月价格=满送优惠价*折扣
                                        double FirstMo=CompuUtils.mul(ActSendPrice,CompuUtils.div(Double.valueOf(getActivityFirstMap.get("FulOff").toString()),10));
                                        //第二步：(首月签约时长-1)
                                        double duration1=CompuUtils.reduce(Dur,1);
                                        //第三步：总价格：满送优惠价*(首月签约时长-1)
                                        double Totalcost1=CompuUtils.mul(ActSendPrice,duration1);
                                        //第三步：总价格+首月价格
                                        double Totalcost=CompuUtils.add(Totalcost1,FirstMo);
                                        //第四步：首月优惠价：总价格/首月签约时长
                                        ActFirstPrice=CompuUtils.div(Totalcost,Dur,2);
                                    }
                                    if(FieldCheckUtil.isMapFieldNotNull(getActivityFirstMap,new String[]{"FulMoney"})){
                                        //第一步：总价格:首月签约时长*满送价格
                                        double Totalcost1=CompuUtils.mul(Dur,ActSendPrice);
                                        //第二步：总价格：总价格-首月立减金额
                                        double Totalcost=CompuUtils.reduce(Totalcost1,Double.valueOf(getActivityFirstMap.get("FulMoney").toString()));
                                        //第三步：首月优惠价：总价格/首月签约时长
                                        ActFirstPrice=CompuUtils.div(Totalcost,Dur,2);
                                    }

                                    //查询活动定价比较记录-满送
                                    Map<String,Object>quFirstId=utilsMapper.getUUID(new HashMap<String,Object>(){{
                                        put("uuid", "QuFirstId");
                                        put("database", Constants.DATA_SOURCE_TCMKT);
                                        put("surface", "tcmkt_activity_quite_first");
                                    }});
                                    if(quFirstId!=null){
                                        int number=Integer.valueOf(quFirstId.get("uuid").toString());
                                        QuFirstId= ComUtils.getLocalTrmSeqNum("bjsy",number);
                                    }else{
                                        QuFirstId=ComUtils.getLocalTrmSeqNum("bjsy",0);
                                    }

                                    //创建活动定价比较记录-首月
                                    Map<String,Object>ActivityQuiteFirst=new HashMap<String,Object>();
                                    ActivityQuiteFirst.put("QuFirstId",QuFirstId);
                                    ActivityQuiteFirst.put("ActId",map.get("ActId"));
                                    ActivityQuiteFirst.put("HouInfoId",str);
                                    ActivityQuiteFirst.put("SouType",3);
                                    ActivityQuiteFirst.put("SouId",QuSendId);
                                    ActivityQuiteFirst.put("SouPricing",ActSendPrice);
                                    ActivityQuiteFirst.put("Duration",Dur);
                                    ActivityQuiteFirst.put("ActType",4);
                                    ActivityQuiteFirst.put("FirDuration",getActivityFirstMap.get("FulDuration"));
                                    ActivityQuiteFirst.put("FulMoney",getActivityFirstMap.get("FulMoney"));
                                    ActivityQuiteFirst.put("FulOff",getActivityFirstMap.get("FulOff"));
                                    ActivityQuiteFirst.put("Pricing",ActFirstPrice);

                                    //把当前活动定价比较记录-首月比较价格对象添加至集合
                                    housingSend.add(new HashMap<String,Object>(){{
                                        put("ActType",4);
                                        put("AssId",QuFirstId);
                                        put("Duration",ActivityQuiteFirst.get("Duration"));
                                        put("Pricing",ActivityQuiteFirst.get("Pricing"));
                                    }});

                                    //创建活动定价比较记录-首月
                                    AddActivityQuiteFirst(ActivityQuiteFirst);
                                }

                                //给活动集合排序
                                Collections.sort(housingSend, new Comparator<Map<String, Object>>() {
                                    public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                                        Double Pricing1 = Double.valueOf(o1.get("Pricing").toString()) ;//从你list里面拿出来的一个
                                        Double Pricing2 = Double.valueOf(o2.get("Pricing").toString()) ; //从你list里面拿出来的第二个
                                        return Pricing1.compareTo(Pricing2);
                                    }
                                });

                                Map<String,Object>housingMap=new HashMap<String,Object>();
                                housingMap.put("ActType",housingSend.get(0).get("ActType"));
                                housingMap.put("AssId",housingSend.get(0).get("AssId"));
                                housingMap.put("Duration",housingSend.get(0).get("Duration"));
                                housingMap.put("Pricing",housingSend.get(0).get("Pricing"));
//
                                housingActivity.add(housingMap);

                            }
                            //折扣为空&&付款周期为空&&满送为空&&首月不为空
                            else if(getActivityFulList.size()<=0&&getActivityPayList.size()<=0&&getActivitySendMap==null ||getActivitySendMap.size()<=0 &&getActivityFirstMap!=null&& getActivityFirstMap.size()>0){
                                //各付款周期活动优惠价
                                List<Map<String,Object>>housingFirst=new ArrayList<Map<String,Object>>();
                                double ActFirstPrice=0;
                                //获取首月签约时长
                                double FirstDuration=Double.valueOf(getActivityFirstMap.get("FulOff").toString());

                                //判断首月是打折还是减金额
                                //打折
                                if(FieldCheckUtil.isMapFieldNotNull(getActivityFirstMap,new String[]{"FulOff"})){
                                    //第一步：获取首月价格=满送优惠价*房源定价
                                    double FirstMo=CompuUtils.mul(UnifiedPricing,CompuUtils.div(Double.valueOf(getActivityFirstMap.get("FulOff").toString()),10));
                                    //第二步：(首月签约时长-1)
                                    double duration1=CompuUtils.reduce(FirstDuration,1);
                                    //第三步：总价格：满送优惠价*(首月签约时长-1)
                                    double Totalcost1=CompuUtils.mul(UnifiedPricing,duration1);
                                    //第三步：总价格+首月价格
                                    double Totalcost=CompuUtils.add(Totalcost1,FirstMo);
                                    //第四步：首月优惠价：总价格/首月签约时长
                                    ActFirstPrice=CompuUtils.div(Totalcost,FirstDuration,2);
                                }
                                if(FieldCheckUtil.isMapFieldNotNull(getActivityFirstMap,new String[]{"FulMoney"})){
                                    //第一步：总价格:首月签约时长*满送价格
                                    double Totalcost1=CompuUtils.mul(FirstDuration,UnifiedPricing);
                                    //第二步：总价格：总价格-首月立减金额
                                    double Totalcost=CompuUtils.reduce(Totalcost1,Double.valueOf(getActivityFirstMap.get("FulMoney").toString()));
                                    //第三步：首月优惠价：总价格/首月签约时长
                                    ActFirstPrice=CompuUtils.div(Totalcost,FirstDuration,2);
                                }

                                //查询活动定价比较记录-满送
                                Map<String,Object>quFirstId=utilsMapper.getUUID(new HashMap<String,Object>(){{
                                    put("uuid", "QuFirstId");
                                    put("database", Constants.DATA_SOURCE_TCMKT);
                                    put("surface", "tcmkt_activity_quite_first");
                                }});
                                if(quFirstId!=null){
                                    int number=Integer.valueOf(quFirstId.get("uuid").toString());
                                    QuFirstId= ComUtils.getLocalTrmSeqNum("bjsy",number);
                                }else{
                                    QuFirstId=ComUtils.getLocalTrmSeqNum("bjsy",0);
                                }

                                //创建活动定价比较记录-首月
                                Map<String,Object>ActivityQuiteFirst=new HashMap<String,Object>();
                                ActivityQuiteFirst.put("QuFirstId",QuFirstId);
                                ActivityQuiteFirst.put("ActId",map.get("ActId"));
                                ActivityQuiteFirst.put("HouInfoId",str);
                                ActivityQuiteFirst.put("SouPricing",UnifiedPricing);
                                ActivityQuiteFirst.put("Duration",FirstDuration);
                                ActivityQuiteFirst.put("ActType",4);
                                ActivityQuiteFirst.put("FirDuration",getActivityFirstMap.get("FulDuration"));
                                ActivityQuiteFirst.put("FulMoney",getActivityFirstMap.get("FulMoney"));
                                ActivityQuiteFirst.put("FulOff",getActivityFirstMap.get("FulOff"));
                                ActivityQuiteFirst.put("Pricing",ActFirstPrice);

                                //把当前活动定价比较记录-首月比较价格对象添加至集合
                                housingFirst.add(new HashMap<String,Object>(){{
                                    put("ActType",4);
                                    put("AssId",QuFirstId);
                                    put("Duration",ActivityQuiteFirst.get("Duration"));
                                    put("Pricing",ActivityQuiteFirst.get("Pricing"));
                                }});

                                //创建活动定价比较记录-首月
                                AddActivityQuiteFirst(ActivityQuiteFirst);

                                //给活动集合排序
                                Collections.sort(housingFirst, new Comparator<Map<String, Object>>() {
                                    public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                                        Double Pricing1 = Double.valueOf(o1.get("Pricing").toString()) ;//从你list里面拿出来的一个
                                        Double Pricing2 = Double.valueOf(o2.get("Pricing").toString()) ; //从你list里面拿出来的第二个
                                        return Pricing1.compareTo(Pricing2);
                                    }
                                });

                                Map<String,Object>housingMap=new HashMap<String,Object>();
                                housingMap.put("ActType",housingFirst.get(0).get("ActType"));
                                housingMap.put("AssId",housingFirst.get(0).get("AssId"));
                                housingMap.put("Duration",housingFirst.get(0).get("Duration"));
                                housingMap.put("Pricing",housingFirst.get(0).get("Pricing"));
//
                                housingActivity.add(housingMap);

                            }

                            //给活动-满减（折扣）集合排序
                            Collections.sort(housingActivity, new Comparator<Map<String, Object>>() {
                                public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                                    Double Pricing1 = Double.valueOf(o1.get("Pricing").toString()) ;//从你list里面拿出来的一个
                                    Double Pricing2 = Double.valueOf(o2.get("Pricing").toString()) ; //从你list里面拿出来的第二个
                                    return Pricing1.compareTo(Pricing2);
                                }
                            });

                            Map<String,Object>housingMap=new HashMap<String,Object>();
                            housingMap.put("ActId",map.get("ActId"));
                            housingMap.put("HouInfoId",str);
                            housingMap.put("ActType",housingActivity.get(0).get("ActType"));
                            housingMap.put("AssId",housingActivity.get(0).get("AssId"));
                            housingMap.put("Duration",housingActivity.get(0).get("Duration"));
                            housingMap.put("Pricing",housingActivity.get(0).get("Pricing"));
                            //创建各活动房源定价
                            QuiteHousing.add(housingMap);

                        }

                    }
                }
                //各房源活动定价排序
                sort(QuiteHousing);
                //获取有效活动房源中间表，并且根据房源分组。
                //并且选出最优活动。
                getActivitHousingNormal(params);
            }
        }
        finally {
            lock.unlock();
        }
    }

    /**
     * 功能描述: 
     * 创建活动定价比较记录-折扣
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/2/27 9:57
     */
    @Transactional(rollbackFor = Exception.class)
    public void AddActivityQuiteFull(Map<String,Object>params){
        try {
            //所有新增处理
            Map<String,Object>commonInsertParms=new HashMap<String,Object>();
            commonInsertParms.put("term", "8");// 创建端 Insert端： 1 租客端 2市场部 3 工程部 4运营部 5财务部 6总经办 7发展部 8定时任务
            commonInsertParms.put("fnc",
                    this.getClass().getSimpleName() + "." + Thread.currentThread().getStackTrace()[1].getMethodName());// 创建Function名
            ParamsCommon.commonInsertParms(commonInsertParms);
            params.putAll(commonInsertParms);
            ActivityMapper.AddActivityQuiteFull(params);
        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
    }

    /**
     * 功能描述:
     * 创建活动定价比较记录-付款周期
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/2/27 9:57
     */
    @Transactional(rollbackFor = Exception.class)
    public void AddActivityQuitePay(Map<String,Object>params){
        try {
            //所有新增处理
            Map<String,Object>commonInsertParms=new HashMap<String,Object>();
            commonInsertParms.put("term", "8");// 创建端 Insert端： 1 租客端 2市场部 3 工程部 4运营部 5财务部 6总经办 7发展部 8定时任务
            commonInsertParms.put("fnc",
                    this.getClass().getSimpleName() + "." + Thread.currentThread().getStackTrace()[1].getMethodName());// 创建Function名
            ParamsCommon.commonInsertParms(commonInsertParms);
            params.putAll(commonInsertParms);
            ActivityMapper.AddActivityQuitePay(params);
        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
    }

    /**
     * 功能描述: 
     * 创建活动定价比较记录-满送
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/2/28 15:52
     */
    @Transactional(rollbackFor = Exception.class)
    public void AddActivityQuiteSend(Map<String,Object>params){
        try {
            //所有新增处理
            Map<String,Object>commonInsertParms=new HashMap<String,Object>();
            commonInsertParms.put("term", "8");// 创建端 Insert端： 1 租客端 2市场部 3 工程部 4运营部 5财务部 6总经办 7发展部 8定时任务
            commonInsertParms.put("fnc",
                    this.getClass().getSimpleName() + "." + Thread.currentThread().getStackTrace()[1].getMethodName());// 创建Function名
            ParamsCommon.commonInsertParms(commonInsertParms);
            params.putAll(commonInsertParms);
            ActivityMapper.AddActivityQuiteSend(params);
        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
    }

    /**
     * 功能描述:
     * 创建各活动房源定价
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/2/28 15:52
     */
    @Transactional(rollbackFor = Exception.class)
    public void AddActivityQuiteHsouing(Map<String,Object>params){
        try {
            //所有新增处理
            Map<String,Object>commonInsertParms=new HashMap<String,Object>();
            commonInsertParms.put("term", "8");// 创建端 Insert端： 1 租客端 2市场部 3 工程部 4运营部 5财务部 6总经办 7发展部 8定时任务
            commonInsertParms.put("fnc",
                    this.getClass().getSimpleName() + "." + Thread.currentThread().getStackTrace()[1].getMethodName());// 创建Function名
            ParamsCommon.commonInsertParms(commonInsertParms);
            params.putAll(commonInsertParms);
            ActivityMapper.AddActivityQuiteHsouing(params);
        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
    }

    /**
     * 功能描述:
     * 创建活动定价比较记录-首月
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/2/28 15:52
     */
    @Transactional(rollbackFor = Exception.class)
    public void AddActivityQuiteFirst(Map<String,Object>params){
        try {
            //所有新增处理
            Map<String,Object>commonInsertParms=new HashMap<String,Object>();
            commonInsertParms.put("term", "8");// 创建端 Insert端： 1 租客端 2市场部 3 工程部 4运营部 5财务部 6总经办 7发展部 8定时任务
            commonInsertParms.put("fnc",
                    this.getClass().getSimpleName() + "." + Thread.currentThread().getStackTrace()[1].getMethodName());// 创建Function名
            ParamsCommon.commonInsertParms(commonInsertParms);
            params.putAll(commonInsertParms);
            ActivityMapper.AddActivityQuiteFirst(params);
        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
    }

    /**
     * 功能描述:
     * 各房源活动定价排序添加至数据库
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/3/2 19:06
     */
    public void sort(List<Map<String,Object>>list){
        //所有新增处理
        Map<String,Object>commonInsertParms=new HashMap<String,Object>();
        commonInsertParms.put("term", "8");// 创建端 Insert端： 1 租客端 2市场部 3 工程部 4运营部 5财务部 6总经办 7发展部 8定时任务
        commonInsertParms.put("fnc",
                this.getClass().getSimpleName() + "." + Thread.currentThread().getStackTrace()[1].getMethodName());// 创建Function名
        ParamsCommon.commonInsertParms(commonInsertParms);
//        //新增活动房源定价之前清空活动房源定价表
//        ActivityMapper.DelActivityQuiteHsouing();
        Stream<Map<String, Object>> stream = list.stream();
        List<Map<String, Object>> list2 = stream.sorted(Ripper::comparator).collect(Collectors.toList());
        String houid=null;
        int Sort=0;
        for(int j=0;j<list2.size();j++){
            Map<String,Object>map=new HashMap<String,Object>();
            map.putAll(list2.get(j));
            if(j==0){
                houid=list2.get(0).get("HouInfoId").toString();
            }
            if(houid.equals(list2.get(j).get("HouInfoId").toString())||houid==list2.get(j).get("HouInfoId").toString()){
                map.put("Sort",Sort);
                Sort++;
            }else{
                Sort=0;
                houid=list2.get(j).get("HouInfoId").toString();
                map.put("Sort",Sort);
                Sort++;
            }
            map.putAll(commonInsertParms);
            //各活动房源定价
            ActivityMapper.AddActivityQuiteHsouing(map);
        }
    }


    /**
     * 功能描述: 
     * 获取有效活动房源中间表，并且根据房源分组。
     * 并且选出最优活动。
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/3/3 10:40
     */
    public void getActivitHousingNormal(Map<String,Object>params){
        List<Map<String,Object>>getActivitHousingNormal=ActivityMapper.getActivitHousingNormal(new HashMap<String,Object>(){{
            put("delfg",0);
            put("Status",0);
            put("HouInfoId",params.get("HouInfoId"));
        }});
        if(getActivitHousingNormal.size()>0){
            for (Map<String,Object> map:getActivitHousingNormal){
                map.put("Sort",0);
                //根据房源编号获取各活动房源定价,取排序第几条
                Map<String,Object>getActivitQuiteHousing=ActivityMapper.getActivitQuiteHousing(map);

                Map<String,Object>quActId=utilsMapper.getUUID(new HashMap<String,Object>(){{
                    put("uuid", "QuActId");
                    put("database", Constants.DATA_SOURCE_TCMKT);
                    put("surface", "tcmkt_activity_quite");
                }});
                if(quActId!=null){
                    int number=Integer.valueOf(quActId.get("uuid").toString());
                    QuActId= ComUtils.getLocalTrmSeqNum("hdzy",number);
                }else{
                    QuActId=ComUtils.getLocalTrmSeqNum("hdzy",0);
                }

                //添加房源活动最优价-主表
                AddActivityQuite(new HashMap<String,Object>(){{
                    put("QuActId",QuActId);
                    put("HouInfoId",getActivitQuiteHousing.get("HouInfoId"));
                    put("ActId",getActivitQuiteHousing.get("ActId"));
                    put("Duration",getActivitQuiteHousing.get("Duration"));
                    put("Pricing",getActivitQuiteHousing.get("Pricing"));
                }});
                if(getActivitQuiteHousing!=null && getActivitQuiteHousing.size()>0){
                    //如果最优价格是类型一的，就去查询比较记录折扣表
                    //1.满减类  2.付款方式  3满送类   4首月类
                    if(getActivitQuiteHousing.get("ActType").equals(1)||getActivitQuiteHousing.get("ActType").toString()=="1"){
                        //根据活动房源最优价关键编号去查询
                        getActivitQuiteHousing.put("QuFulId",getActivitQuiteHousing.get("AssId"));
                        getActivitQuiteFull(getActivitQuiteHousing);
                    }
                    else if(getActivitQuiteHousing.get("ActType").equals(2)||getActivitQuiteHousing.get("ActType").toString()=="2"){
                        //根据活动房源最优价关键编号去查询
                        getActivitQuiteHousing.put("QuPayId",getActivitQuiteHousing.get("AssId"));
                        getActivitQuitePay(getActivitQuiteHousing);
                    }
                    else if(getActivitQuiteHousing.get("ActType").equals(3)||getActivitQuiteHousing.get("ActType").toString()=="3"){
                        //根据活动房源最优价关键编号去查询
                        getActivitQuiteHousing.put("QuSendId",getActivitQuiteHousing.get("AssId"));
                        getActivitQuiteSend(getActivitQuiteHousing);
                    }
                    else if(getActivitQuiteHousing.get("ActType").equals(4)||getActivitQuiteHousing.get("ActType").toString()=="4"){
                        //根据活动房源最优价关键编号去查询
                        getActivitQuiteHousing.put("QuFirstId",getActivitQuiteHousing.get("AssId"));
                        getActivitQuiteFirst(getActivitQuiteHousing);
                    }

                }
            }
        }
    }

    /**
     * 功能描述:
     * 创建活动定价比较记录-主表
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/2/28 15:52
     */
    @Transactional(rollbackFor = Exception.class)
    public void AddActivityQuite(Map<String,Object>params){
        try {
            //所有新增处理
            Map<String,Object>commonInsertParms=new HashMap<String,Object>();
            commonInsertParms.put("term", "8");// 创建端 Insert端： 1 租客端 2市场部 3 工程部 4运营部 5财务部 6总经办 7发展部 8定时任务
            commonInsertParms.put("fnc",
                    this.getClass().getSimpleName() + "." + Thread.currentThread().getStackTrace()[1].getMethodName());// 创建Function名
            ParamsCommon.commonInsertParms(commonInsertParms);
            params.putAll(commonInsertParms);
            ActivityMapper.AddActivityQuite(params);
        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
    }

    /**
     * 功能描述:
     * 创建活动定价比较记录-详表
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/2/28 15:52
     */
    @Transactional(rollbackFor = Exception.class)
    public void AddActivityQuiteInfo(Map<String,Object>params){
        try {
            //所有新增处理
            Map<String,Object>commonInsertParms=new HashMap<String,Object>();
            commonInsertParms.put("term", "8");// 创建端 Insert端： 1 租客端 2市场部 3 工程部 4运营部 5财务部 6总经办 7发展部 8定时任务
            commonInsertParms.put("fnc",
                    this.getClass().getSimpleName() + "." + Thread.currentThread().getStackTrace()[1].getMethodName());// 创建Function名
            ParamsCommon.commonInsertParms(commonInsertParms);
            params.putAll(commonInsertParms);
            ActivityMapper.AddActivityQuiteInfo(params);
        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
    }
    
    /**
     * 功能描述: 
     * 首月开始
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/3/3 16:28
     */
    public void getActivitQuiteFirst(Map<String,Object>params){
        //根据编号获取活动定价比较记录-首月记录
        Map<String,Object>getActivitQuiteFirst=ActivityMapper.getActivitQuiteFirst(params);
        //判断首月记录是否为空
        if(getActivitQuiteFirst!=null && getActivitQuiteFirst.size()>0){
            //然后把当前规则添加至房源最优价详表
            AddActivityQuiteInfo(new HashMap<String,Object>(){{
                put("QuActId",QuActId);
                put("HouInfoId",params.get("HouInfoId"));
                put("ActId",params.get("ActId"));
                put("ActType",getActivitQuiteFirst.get("ActType"));
                put("SouId",getActivitQuiteFirst.get("QuFirstId"));
                put("Money",getActivitQuiteFirst.get("FulMoney"));
                put("Discount",getActivitQuiteFirst.get("FulOff"));
            }});
            //然后判断当前首月活动中是否有来源规则
            if(FieldCheckUtil.isMapFieldNotNull(getActivitQuiteFirst,new String[]{"SouType"})){
                //当前规则来源规则等于三的时候
                if(getActivitQuiteFirst.get("SouType").equals(3)||getActivitQuiteFirst.get("SouType").toString()=="3"){
                    //然后判断当前首月活动中是否有来源规则编号
                    if(FieldCheckUtil.isMapFieldNotNull(getActivitQuiteFirst,new String[]{"SouId"})){
                        //然后根据来源规则查询满送
                        Map<String,Object>getActivitQuiteSend=ActivityMapper.getActivitQuiteSend(new HashMap<String,Object>(){{
                            put("delfg",0);
                            put("QuSendId",getActivitQuiteFirst.get("SouId"));
                        }});
                        //判断满送不为空
                        if(getActivitQuiteSend!=null && getActivitQuiteSend.size()>0){
                            //然后把当前规则添加至房源最优价详表
                            AddActivityQuiteInfo(new HashMap<String,Object>(){{
                                put("QuActId",QuActId);
                                put("HouInfoId",params.get("HouInfoId"));
                                put("ActId",params.get("ActId"));
                                put("ActType",getActivitQuiteSend.get("ActType"));
                                put("SouId",getActivitQuiteSend.get("QuSendId"));
                                put("SendDuration",getActivitQuiteSend.get("SenSend"));
                            }});
                            //然后判断当前首月活动中是否有来源规则
                            if(FieldCheckUtil.isMapFieldNotNull(getActivitQuiteSend,new String[]{"SouType"})){
                                //当前规则来源规则等于二的时候
                                if(getActivitQuiteSend.get("SouType").equals(2)||getActivitQuiteSend.get("SouType").toString()=="2"){
                                    //然后判断当前满送活动中是否有来源规则编号
                                    if(FieldCheckUtil.isMapFieldNotNull(getActivitQuiteSend,new String[]{"SouId"})){
                                        //然后根据来源规格编号查询付款周期
                                        Map<String,Object>getActivitQuitePay=ActivityMapper.getActivitQuitePay(new HashMap<String,Object>(){{
                                            put("delfg",0);
                                            put("QuPayId",getActivitQuiteSend.get("SouId"));
                                        }});
                                        if(getActivitQuitePay!=null && getActivitQuitePay.size()>0){
                                            //然后把当前规则添加至房源最优价详表
                                            AddActivityQuiteInfo(new HashMap<String,Object>(){{
                                                put("QuActId",QuActId);
                                                put("HouInfoId",params.get("HouInfoId"));
                                                put("ActId",params.get("ActId"));
                                                put("ActType",getActivitQuitePay.get("ActType"));
                                                put("SouId",getActivitQuitePay.get("QuPayId"));
                                                put("PayType",getActivitQuitePay.get("PayType"));
                                                put("Money",getActivitQuitePay.get("FulMoney"));
                                                put("Discount",getActivitQuitePay.get("FulOff"));
                                            }});
                                            //然后判断当前付款周期中是否有来源规则
                                            if(FieldCheckUtil.isMapFieldNotNull(getActivitQuitePay,new String[]{"SouType"})){
                                                if(getActivitQuitePay.get("SouType").equals(1)||getActivitQuitePay.get("SouType").toString()=="1"){
                                                    if(FieldCheckUtil.isMapFieldNotNull(getActivitQuitePay,new String[]{"SouId"})){
                                                        //然后根据来源规格编号查询折扣
                                                        Map<String,Object>getActivitQuiteFull=ActivityMapper.getActivitQuiteFull(new HashMap<String,Object>(){{
                                                            put("delfg",0);
                                                            put("QuFulId",getActivitQuitePay.get("SouId"));
                                                        }});
                                                        //然后把当前规则添加至房源最优价详表
                                                        AddActivityQuiteInfo(new HashMap<String,Object>(){{
                                                            put("QuActId",QuActId);
                                                            put("HouInfoId",params.get("HouInfoId"));
                                                            put("ActId",params.get("ActId"));
                                                            put("ActType",getActivitQuiteFull.get("ActType"));
                                                            put("SouId",getActivitQuiteFull.get("QuFulId"));
                                                            put("Money",getActivitQuiteFull.get("FulMoney"));
                                                            put("Discount",getActivitQuiteFull.get("FulOff"));
                                                        }});
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

            }

        }
    }

    /**
     * 功能描述:
     * 满送开始
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/3/3 16:28
     */
    public void getActivitQuiteSend(Map<String,Object>params){
        //然后根据来源规则查询满送
        Map<String,Object>getActivitQuiteSend=ActivityMapper.getActivitQuiteSend(params);
        //判断满送不为空
        if(getActivitQuiteSend!=null && getActivitQuiteSend.size()>0){
            //然后把当前规则添加至房源最优价详表
            AddActivityQuiteInfo(new HashMap<String,Object>(){{
                put("QuActId",QuActId);
                put("HouInfoId",params.get("HouInfoId"));
                put("ActId",params.get("ActId"));
                put("ActType",getActivitQuiteSend.get("ActType"));
                put("SouId",getActivitQuiteSend.get("QuSendId"));
                put("SendDuration",getActivitQuiteSend.get("SenSend"));
            }});
            //然后判断当前首月活动中是否有来源规则
            if(FieldCheckUtil.isMapFieldNotNull(getActivitQuiteSend,new String[]{"SouType"})){
                //当前规则来源规则等于二的时候
                if(getActivitQuiteSend.get("SouType").equals(2)||getActivitQuiteSend.get("SouType").toString()=="2"){
                    //然后判断当前满送活动中是否有来源规则编号
                    if(FieldCheckUtil.isMapFieldNotNull(getActivitQuiteSend,new String[]{"SouId"})){
                        //然后根据来源规格编号查询付款周期
                        Map<String,Object>getActivitQuitePay=ActivityMapper.getActivitQuitePay(new HashMap<String,Object>(){{
                            put("delfg",0);
                            put("QuPayId",getActivitQuiteSend.get("SouId"));
                        }});
                        if(getActivitQuitePay!=null && getActivitQuitePay.size()>0){
                            //然后把当前规则添加至房源最优价详表
                            AddActivityQuiteInfo(new HashMap<String,Object>(){{
                                put("QuActId",QuActId);
                                put("HouInfoId",params.get("HouInfoId"));
                                put("ActId",params.get("ActId"));
                                put("ActType",getActivitQuitePay.get("ActType"));
                                put("SouId",getActivitQuitePay.get("QuPayId"));
                                put("PayType",getActivitQuitePay.get("PayType"));
                                put("Money",getActivitQuitePay.get("FulMoney"));
                                put("Discount",getActivitQuitePay.get("FulOff"));
                            }});
                            //然后判断当前付款周期中是否有来源规则
                            if(FieldCheckUtil.isMapFieldNotNull(getActivitQuitePay,new String[]{"SouType"})){
                                if(getActivitQuitePay.get("SouType").equals(1)||getActivitQuitePay.get("SouType").toString()=="1"){
                                    if(FieldCheckUtil.isMapFieldNotNull(getActivitQuitePay,new String[]{"SouId"})){
                                        //然后根据来源规格编号查询折扣
                                        Map<String,Object>getActivitQuiteFull=ActivityMapper.getActivitQuiteFull(new HashMap<String,Object>(){{
                                            put("delfg",0);
                                            put("QuFulId",getActivitQuitePay.get("SouId"));
                                        }});
                                        //然后把当前规则添加至房源最优价详表
                                        AddActivityQuiteInfo(new HashMap<String,Object>(){{
                                            put("QuActId",QuActId);
                                            put("HouInfoId",params.get("HouInfoId"));
                                            put("ActId",params.get("ActId"));
                                            put("ActType",getActivitQuiteFull.get("ActType"));
                                            put("SouId",getActivitQuiteFull.get("QuPayId"));
                                            put("Money",getActivitQuiteFull.get("FulMoney"));
                                            put("Discount",getActivitQuiteFull.get("FulOff"));
                                        }});
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    /**
     * 功能描述:
     * 付款周期开始
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/3/3 16:28
     */
    public void getActivitQuitePay(Map<String,Object>params){
        //然后根据来源规格编号查询付款周期
        Map<String,Object>getActivitQuitePay=ActivityMapper.getActivitQuitePay(params);
        if(getActivitQuitePay!=null && getActivitQuitePay.size()>0){
            //然后把当前规则添加至房源最优价详表
            AddActivityQuiteInfo(new HashMap<String,Object>(){{
                put("QuActId",QuActId);
                put("HouInfoId",params.get("HouInfoId"));
                put("ActId",params.get("ActId"));
                put("ActType",getActivitQuitePay.get("ActType"));
                put("SouId",getActivitQuitePay.get("QuPayId"));
                put("PayType",getActivitQuitePay.get("PayType"));
                put("Money",getActivitQuitePay.get("FulMoney"));
                put("Discount",getActivitQuitePay.get("FulOff"));
            }});
            //然后判断当前付款周期中是否有来源规则
            if(FieldCheckUtil.isMapFieldNotNull(getActivitQuitePay,new String[]{"SouType"})){
                if(getActivitQuitePay.get("SouType").equals(1)||getActivitQuitePay.get("SouType").toString()=="1"){
                    if(FieldCheckUtil.isMapFieldNotNull(getActivitQuitePay,new String[]{"SouId"})){
                        //然后根据来源规格编号查询折扣
                        Map<String,Object>getActivitQuiteFull=ActivityMapper.getActivitQuiteFull(new HashMap<String,Object>(){{
                            put("delfg",0);
                            put("QuFulId",getActivitQuitePay.get("SouId"));
                        }});
                        //然后把当前规则添加至房源最优价详表
                        AddActivityQuiteInfo(new HashMap<String,Object>(){{
                            put("QuActId",QuActId);
                            put("HouInfoId",params.get("HouInfoId"));
                            put("ActId",params.get("ActId"));
                            put("ActType",getActivitQuiteFull.get("ActType"));
                            put("SouId",getActivitQuiteFull.get("QuPayId"));
                            put("Money",getActivitQuiteFull.get("FulMoney"));
                            put("Discount",getActivitQuiteFull.get("FulOff"));
                        }});
                    }
                }
            }
        }
    }

    /**
     * 功能描述:
     * 付款折扣开始
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/3/3 16:28
     */
    public void getActivitQuiteFull(Map<String,Object>params){
            //然后根据来源规格编号查询折扣
            Map<String,Object>getActivitQuiteFull=ActivityMapper.getActivitQuiteFull(params);
            //然后把当前规则添加至房源最优价详表
            AddActivityQuiteInfo(new HashMap<String,Object>(){{
                put("QuActId",QuActId);
                put("HouInfoId",params.get("HouInfoId"));
                put("ActId",params.get("ActId"));
                put("ActType",getActivitQuiteFull.get("ActType"));
                put("SouId",getActivitQuiteFull.get("QuPayId"));
                put("Money",getActivitQuiteFull.get("FulMoney"));
                put("Discount",getActivitQuiteFull.get("FulOff"));
            }});
    }

}
